package com.xiaoxu.privatechat.dao.common;

import com.xiaoxu.privatechat.entity.common.MsgLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description 消息记录数据库处理层
 * @author xiaoxu
 * @date 2023/2/13
 */
@Repository
public interface MsgLogDao extends JpaRepository<MsgLog, Long>{
	

	/**
	 * @description 根据消息记录id查询
	 * @param id 消息日志id
	 * @return MsgLog
	 */
	@Query("select ml from MsgLog ml where ml.id = :id")
	MsgLog find(@Param("id")Long id);

	/**
	 * @description 根据账户id和状态查询消息日志
	 * @param accountId 账户id
	 * @param status 状态
	 * @return List<MsgLog>
	 */
	List<MsgLog> findByAccountIdAndStatus(Long accountId,int status);

	/**
	 * @description 根据内容id查询日志
	 * @param msgContentId 内容id
	 * @return List<MsgLog>
	 */
	List<MsgLog> findByMsgContentId(Long msgContentId);
	
}
